#include<stdio.h>
#include<string.h>
double f(char a[1005],int i)
{
	double temp=0,fu=1;
	double n=0;
	if(a[i]=='-')
	{
		fu=-1;i++;
	}
	while(a[i]>='0'&&a[i]<='9')
		n=n*10 + (a[i++]-'0') ;
	if(a[i]=='.')
	{	
		while(a[i]!=';')	i++;
		while(a[--i]!='.')
			temp=temp*0.1+(a[i]-'0');
	}
	return fu*(n+0.1*temp);
}
int main()
{
	char a[1005];
	int i,j,k=0,l=1;
	double x=0,y=0;
	gets(a);
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]=='&')
			l=f(a,i+1);
		if(!(a[i]>='A'&&a[i]<='Z'))
			continue;
		if(a[i]=='M')
			k=f(a,i+1)+1;
		if(k>0)
			k--;
		else
			l=1;
		
		if(a[i]=='W')
			y+=f(a,i+1)*l;
		if(a[i]=='S')
			y-=f(a,i+1)*l;
		if(a[i]=='A')
			x-=f(a,i+1)*l;
		if(a[i]=='D')
			x+=f(a,i+1)*l;
	}
	printf("%.6lf %.6lf\n",x,y);
	return 0;
}
